﻿




using System.Web.Mvc;
using Hotpot.Modules.Tags.Services;

namespace Hotpot.Modules.Tags.ModelBinders
{
    public class TagModelBinder : IModelBinder
    {
        private readonly ITagService tagService;

        public TagModelBinder(ITagService tagService)
        {
            this.tagService = tagService;
        }

        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            string tagName = (string)bindingContext.ValueProvider["tagName"].RawValue;

            return tagService.GetTag(tagName);
        }
    }
}
